package com.txy.webmanagement.mapper;

import com.txy.webmanagement.model.SysUser;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface SysUserMapper {
    @Select("select * from sys_user ")
    List<SysUser> findAll();

    @Select("<script> select uuid,user_name as userName,password,type_id as typeId,enable,nick_name nickName,create_time as createTime from sys_user where user_name= #{userName} </script>")
    List<SysUser> getSysUserByUserName(@Param("userName") String userName);

    @Insert("insert into sys_user(uuid,user_name,password,type_id,enable,nick_name,create_time) values(#{uuid}, #{userName}, #{password}, #{typeId},#{enable,jdbcType=BIGINT},#{nickName}, #{createTime, jdbcType=TIMESTAMP})")
    int add(SysUser user);

    @Update({"<script>", "update sys_user", "<set>",
            "<if test='userName != null'>", "user_name = #{userName} ,", "</if>",
            "<if test='nickName != null'>", "nick_name = #{nickName} ,", "</if>",
            "<if test='password != null'>", "password = #{password} ,", "</if>",
            "<if test='typeId != null'>", "type_id = #{typeId} ,", "</if>",
            "<if test='enable != null'>", "enable = #{enable} ,", "</if>",
             "</set>", "where uuid = #{uuid}", "</script>"})
    Boolean update(SysUser user);
}
